package test.tongdun;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @description:
 * @author: w_jingbo
 * @date: 2023/9/22
 * @Copyright: 博客：http://coisini.wang
 */
public class Main {

    static class Unionfind{
        private int[] parent ;
        private int count ;
        public Unionfind(int n){
            parent = new int[n] ;
            for (int i = 0; i < n; i++) {
                parent[i] = i ;

            }
            count = n ;
        }

        public int find(int i){
            if(parent[i] != i){
                parent[i] = find(parent[i]);
            }
            return parent[i];
        }

        public void union(int i , int j){
            int rooti = find(i) ;
            int rootj = find(j);
            if(rooti != rootj){
                parent[rootj] = rootj ;
                count--;
            }
        }

        public int getCount(){
            return count;
        }




    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] arr =new String[n] ;
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLine();
        }
        System.out.println(countSim(arr));

        

    }

    public static int countSim(String[] strs){
        int n = strs.length ;
        Unionfind uf = new Unionfind(n);
        for(int i = 0 ; i < n-1 ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(isSim(strs[i],strs[j])){
                    uf.union(i,j);
                }
            }

        }
        return uf.getCount() ;
    }

    public static boolean isSim(String s1, String s2){
        if(s1.length() != s2.length()){
            return  false;
        }
        char[] c1 = s1.toCharArray();
        char[] c2 = s2.toCharArray();
        Arrays.sort(c1);
        Arrays.sort(c2);
        return Arrays.equals(c1,c2);

    }



    /*
    //贪心
    int cap = Integer.parseInt(in.nextLine()) ;
        int n = Integer.parseInt(in.nextLine()) ;
        int[] arr = new int[n] ;
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(in.nextLine()) ;
        }
        Arrays.sort(arr);
        int tatget = cap ;
        for (int i = n-1; i >= 0; i--) {
            if(tatget == 0){
                System.out.println(0);
                return;
            }
            if(tatget >= arr[i]){
                tatget -= arr[i] ;
            }
        }
        System.out.println(tatget);
     */
}
